﻿var isCache = true; //是否有缓存
try {
	Utility.keyConvert();
} catch (e) {
	// statements
	console.log(e);
}

//EVM.cookie.setValue('TV_CST_TOKEN', "e3dd30a73e2e0a9039252c6f28a207f5");
//EVM.cookie.setValue('TV_CST_NAME', "陈国柏");
//EVM.cookie.setValue('TV_CST_HEADIMG', "http://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTIwibXqnph3NduToTqzLtbHjQSb3MupGlFoSG8eARPR1bnKXwdczPMyQRdrajsn4V0kLgumnwicib6Kw/132");

//获取机顶盒或浏览器信息
var env = evm.getStbBrowser();

function cookie(k, v) {
	if (v != undefined && typeof v == 'string') {
		evm.cookie(k, v);
		return;
	}
	if (!!evm.cookie(k)) {
		return evm.cookie(k);
	}
}

function log(argument, arguments) {
	console.log(argument, arguments)
}
/*
 * $cmsIndex首页视图模块
 * 依赖:
 */
var cmsIndex = (function () {
	var mod = {};

	//配置项
	var config = mod.config = {
		//开启cookie开关
		cookieSwitch: true,
		cookieKey: 'cmsIndex',
		//模拟数据配置
		mockData: {
			//URI查询标示符
			key: '[mdata]',
			//文件目录
			dir: '../source/mockData'
		},
		//调试输出开关
		debug: false
	};

	var localData = mod.localData = {
		indexSource: '[mdata]/index.js'
	};
	//接口数据缓存
	var jsonCache = {};

	//各模块焦点切换的配置
	var modules = mod.modules = [];

	//当前模块的索引值,被引用的模块
	moduleId = 0,
		module = null,
		moduleGuid = 0,
		moduleCount = -1;

	mod.addModule = function () {
		return moduleCount += 1;
	};

	//moduleGuid存取器
	mod.moduleGuid = function (id) {
		if (typeof id == 'number') moduleGuid = id;
		return moduleGuid;
	};

	if (config.cookieSwitch && config.cookieKey) {
		//read cookie
		var pageCookie = cookie(config.cookieKey);
		if (pageCookie) {
			pageCookie = pageCookie.split(',');

			if (pageCookie.length > 0) {
				var moduleCookie = mod.moduleCookie = pageCookie[0].split('.');

				if (pageCookie[1]) {
					var viewportCookie = mod.viewportCookie = moduleCookie;
					moduleCookie = mod.moduleCookie = pageCookie[1].split('.');

				}
				if (pageCookie[2]) {
					var parentCookie = mod.parentCookie = pageCookie[2].split('.');
				}
			}
		}

		//清除cookie
		evm.cutCookie(config.cookieKey);
	}
	//添加视图按键管理器
	mod.addListener = function () {
		evm.controller.subscribe({
			type: 1,
			method: 'add',
			callback: mod.grabEvent,
			context: mod
		});
	};
	// // console.log(mod)
	//移除视图按键管理器
	mod.removeListener = function () {
		// console.log( mod.grabEvent,'removeListener')
		evm.controller.subscribe({
			type: 1,
			method: 'remove',
			callback: mod.grabEvent,
			context: mod
		});

	};
	// // console.log(module)
	//视图按键管理
	mod.grabEvent = function (key) {
		// console.log(key, 'key')
		var me = mod;
		// event.stopPropagation()
		// event.preventDefault()
		//拦截返回键,方法返回isBlock是1或0,默认0不拦截
		var isBlock = 0;
		if (module && module.grabEvent) {
			isBlock = module.grabEvent(key) || 0;
		}
		return isBlock;
	};
	//模块存取器
	mod.module = function (mID) {
		if (modules[mID]) {
			module = modules[mID].module || null;
		}
		return module;
	};

	//切换当前模块
	mod.handle = function (directive) {
		var me = mod;
		if (modules[moduleId].map &&
			(typeof modules[moduleId].map[directive] == 'number')) {

			moduleId = modules[moduleId].map[directive];

			return me.module(moduleId);
		}
	};
	mod.paint = function () {
		var me = mod;
		modelInit();
		me.addListener();
		return me;
	};
	mod.run = function () {
		var me = mod;
		//默认moduleId = 0 导航栏
		//cookie得到焦点
		var nav = mod.module(moduleId);
		cmsIndex.handle('right');
		//控制器管理按键
		evm.on(document, (!env.stb ? 'keydown' : (env.stb == 'iPanel' ?
			'irkeypress' : 'keydown')), evm.controller, evm);

		me.paint();

		return me;
	};

	return mod;

})();

//ajax 封装  请先于api.js 注册
function GetDatas(url, params, callback) { //地址名，参数内容
	// console.log(API_URL.baseURL + API_URL[url])
	http(API_URL.baseURL + API_URL[url], params, callback)
}

function http(url, params, callback) {
	$.ajax({
		type: 'get',
		// dataType: "jsonp",
		data: params,
		jsonp: "callback",
		url: url,
		success: function (data) {
			callback(null, data)
		},
		error: function (xhr, textStatus, errorThrown) {
			callback(errorThrown)
		}
	});
}

(function (window) {

	var window = window,
		TV = function (selector, root) {
			if (typeof selector !== 'string') {
				return;
			};
			return new Evm.uber.init(selector.replace(/^\s*|\s$/g, ''), root);
		};
	//路由劫持
	var arr = window.location.pathname.split('/');
	pageName = arr[arr.length - 1];
	// console.log(pageName)
	switch (pageName) {
		//      case 'areaList.html':
		case 'myHelp.html':
			// case 'questionList.html':
		case 'helpListDetail.html':
			//      case 'detailActivety.html':
		case 'myShare.html':
			if (!($.cookie('TV_CST_NAME') && $.cookie('TV_CST_NAME') != 'null')) {
				window.location.href = '/login.html'
			}
			break;

			//		case 'play.html':
			//		case 'detailPage.html':
			//			var token = $.cookie('TV_CST_TOKEN');
			//			if (token!=""||token!='undefined'||token!=undefined||token!=null) {
			//				var params = {
			//				cid: TV.GetParam("id"),
			//				type: "tv",
			//				access_token: token,
			//			};
			//			http(API_URL.baseURL + API_URL[addRecords], params, function(err, res) {});
			//			}
			//			break;
	}
	TV.userLogin = function () { //自动登录
		var random = parseInt(Math.random() * 10000);
		var scankey = hex_md5(hardware.smartCard.serialNumber + random);
		var params = {
			sign: scankey,
			rand: random,
			smartcardno: hardware.smartCard.serialNumber
		}
		http(API_URL.loginURL + 'home/auth/getCardnoCode', params, function (err, res) {
			var code = res.data.code;
			var mess = {
				code: code,
				cardno: hardware.STB.serialNumber,
				sign: scankey
			}
			http(API_URL.loginURL + 'home/auth/getAccessToken', mess, function (err, data) {
				if (data.code == '803' || data.code == '803') {
					window.location.href = '../pages/login.html'
				} else {
					$.cookie('TV_CST_TOKEN', data.data.access_token, {
						path: '/'
					});
					EVM.cookie.setValue('TV_CST_TOKEN', data.data.access_token);
				}
			})
		})
	}
	//左上角区域名

	TV.getHeader = function () {
		var area_id = TV.GetParam('area_id') || $.cookie('TV_CST_AREA') || 0;
		$.cookie('TV_CST_AREA', area_id, {
			path: '/'
		});
		var str = '';
		str += '<div id="headName" class="head-name"><img src=".';
		if (pageName && pageName != 'index.html') {
			str += '.'
		}
		str += '/images/' + area_id + '.png" alt=""></div>';

		$('body').append(str);
	}
	//用户登录信息
	TV.UserMess = function () { //用户名称
		var str = '';
		$("#login").html(str)
		var username = EVM.cookie.getValue('TV_CST_NAME');
		var userImg = EVM.cookie.getValue('TV_CST_HEADIMG');
		// console.log(username)
		var user = username && username != 'null' ? username : '请登录'
		str += '  <div id="login" class="login"><div id="userName">' + user + '</div>';
		if (userImg && userImg != 'null') {
			str += '<div class=" head-img user-img">';
			str += "<img src=" + userImg + ">"
			str += '</div>';

			$(".login-bg").hide();
			loginsize = true
		} else {
			str += '<div class="head-img"></div>';

			$(".login-bg").show();

			loginsize = false
		}

		str += '</div>';
		if (!modelIndex.disUser) {
			$('body').append(str)

		}
		// if(userImg){
		//     // console.log()
		//     $('.head-img').attr("style", "background: url("+userImg+");");
		//     $('.head-img').attr("style", "background-size: 100% 100%");
		// }

		return username && username != 'null' ? 1 : 0
	}
	//非列表页操作
	TV.IndexOpt = function (containerId, listName, index) { //外层id,内层模块name,位置
		var elem = $("#" + containerId).children("." + listName);
		var elemHeader = $(".head-img");
		elemHeader.removeClass("header-active");
		// console.log(index)
		for (var i = 0; i < elem.length; i++) {
			elem[i].className = listName;
		}
		if (index == -1) {
			elemHeader.addClass("header-active");
		} else {
			elem[index].className = elem[index].className + ' active';
		}
	}

	//提示 自适应内容大小    
	TV.PromptMsg = function (title, timeout) { //内容，时间 
		var str = '';
		var msg = title ? title : '请输入提示内容';
		var time = timeout || 2000;
		// console.log()
		if ($('#pormptDiv').length == 0) {
			str = '<div class="pormpt-div" id="pormptDiv"><div class="prompt-msg"  id="pormptMsg">' +
				msg +
				'</div> </div>'
			$("body").append(str);
		} else {
			$('#pormptMsg').html(msg)
			$('#pormptDiv').attr("style", "display:block");
		}

		setTimeout(function () {
			$('#pormptDiv').fadeOut()
		}, time);
	};

	//取url参数
	TV.GetParam = function (Name) {
		var paramName = Name ? Name : 'id'
		paramValue = "";
		isFound = false;
		if (window.location.search.indexOf("?") == 0 && window.location.search.indexOf("=") > 1) {
			arrSource = decodeURI(window.location.search).substring(1, window.location.search.length).split("&");
			i = 0;
			while (i < arrSource.length && !isFound) {
				if (arrSource[i].indexOf("=") > 0) {
					if (arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase()) {
						paramValue = arrSource[i].split("=")[1];
						isFound = true;
					}
				}
				i++;
			}
		}
		return paramValue;
	}

	//键值包装转换
	TV.GetKey = function (key) {
		var keyState = '';
		// event.stopPropagation();
		// event.preventDefault();
		//拦截返回键,方法返回isBlock是1或0,默认0不拦截
		var isBlock = 0;
		switch (key) {
			case keymap.Enrich.UP:
			case keymap.iPanel.UP:
			case keymap.DVN.UP:
				keyState = 'up';
				break;
			case keymap.Enrich.DOWN:
			case keymap.iPanel.DOWN:
			case keymap.DVN.DOWN:
				keyState = 'down';
				break;
			case keymap.Enrich.LEFT:
			case keymap.iPanel.LEFT:
			case keymap.DVN.LEFT:
				keyState = 'backwards';
				break;
			case keymap.Enrich.RIGHT:
			case keymap.iPanel.RIGHT:
			case keymap.DVN.RIGHT:
				keyState = 'forwards';
				break;
			case keymap.SELECT:
			case keymap.SELECT2:
				keyState = 'enter';
				break;
			case keymap.Enrich.BACK:
			case keymap.iPanel.BACK:
			case keymap.DVN.BACK:
				keyState = 'back';
				break;
			case keymap.Inspur.EXIT:
			case keymap.iPanel.EXIT:
			case 0:
				window.location.href = "index.html";
				break;
		}
		return json = {
			keyState: keyState,
			isBlock: isBlock
		};
	}

	TV.callAppFn = function () {
		//茁壮
		var str = '{"id":"20","name":"startAPP","value":"cn.chen.sipcall","param":""}';
		Android.JSONCall(str);
		//创维
		Utility.startApkByIntent("cn.chen.sipcall.startapp", "");
	}

	//menu型内容分页处理 data
	TV.pageListOpt = function (data, pageSize, nowPage, listName, isNav) {
		this.str = '';
		this.totalPage = parseInt(data.length % pageSize == 0 ? data.length / pageSize : data.length / pageSize + 1);
		var size = (nowPage - 1) * pageSize;
		var list = data.slice(size, size + pageSize);
		for (var i = 0; i < list.length; i++) {
			this.str += '<li data-id=' + list[i].id + ' class=' + listName + ' is_volunteer=' + list[i].is_volunteer + ' is_menu=' + list[i].is_menu + ' category=' + list[i].category + ' type_style=' + list[i].type_style + ' data_content=' + list[i].name + ' status=' + list[i].status + ' api=' + list[i].api + ' data_size=' + list[i].size + ' data_number=' + list[i].numbers + ' list_name=' + list[i].list_name
			if (isNav && list[i].isCMod) {
				this.str += ' data-status=' + list[i].isCMod
			}
			this.str += '><div class=list_content>' + list[i].name + '</div></li>';
		}
		return {
			totalPage: this.totalPage,
			length: list.length,
			str: this.str
		}
	}
	// 文章自动播放
	TV.articleMove = function (directive, thisContain, thisDetail, time) {
		var timeMove = time || 20;
		var thisContain = document.getElementById(thisContain);
		var thisIntro = document.getElementById(thisDetail);
		clearInterval(articleRun);

		function Marquee() {
			if (directive == 'down') {
				if (thisIntro.scrollHeight - thisContain.scrollTop <= thisContain.offsetHeight) {
					clearInterval(articleRun);
				} else {
					thisContain.scrollTop++
				}
			} else {
				if (thisContain.scrollTop == 0) {
					clearInterval(articleRun);
				} else {
					thisContain.scrollTop--
				}
			}
			// console.log('内容高度',thisIntro.scrollHeight,'内容高度',thisContain.scrollTop,'容器顶部', thisContain.offsetHeight,'容器高度',thisIntro.offsetHeight)
		}
		articleRun = setInterval(Marquee, timeMove)
	}
	//列表操作   

	TV.ListOperation = function (json) {
		this.direction = json.direction !== undefined && json.direction !== null && json.direction !== '' && json.direction ? json.direction : ''; // 方向 回退的位置  默认无，为单列表界面
		this.structure = json.structure !== undefined && json.structure !== null && json.structure !== '' && json.structure ? json.structure : 1; // 结构 左右结构或上下结构  确保direction不为空 默认左右
		this.type = json.type !== undefined && json.type !== null && json.type !== '' && json.type ? parseInt(json.type) : 1; //  类型 1 是多行单列 2是多列单行 3 是多行多列  默认是多行单列
		this.isLike = json.isLike !== undefined && json.isLike !== null && json.isLike !== '' && json.isLike ? json.isLike : false; // 是否开启点赞功能 默认是否
		this.status = json.status !== undefined && json.status !== null && json.status !== '' && json.status ? json.status : 1; // 框位置 1在外框0在点赞框 默认外框
		this.key = json.key; //  操作键位 backwards左 forwards右 up上 down下 pageUph上一页 pageDown下一页 必填 无默认
		this.nowPage = json.nowPage ? parseInt(json.nowPage) : 1; //当前页数
		this.totalPage = json.totalPage ? parseInt(json.totalPage) : 1; //总页数
		this.pageSize = json.pageSize ? parseInt(json.pageSize) : 1; //列表总数
		this.length = json.length ? parseInt(json.length) : 1; //实际列表数量 
		this.index = parseInt(json.index); //坐标位置
		this.rowHeight = json.rowHeight ? json.rowHeight : 2; //多列模块行数
		this.isMenu = json.isMenu || 0
	}

	TV.ListOperation.prototype = {
		init: function () {
			this.Operation();
		},
		operation: function () {
			var position = ''; //下一页or下一页
			var direction = ''; //退出模块的方向
			var menuStatus = ''; //第二个模块的状态

			switch (this.type) {

				case 1: //多行单列
					switch (this.key) {
						case 'backwards': //左
							if (this.isLike && this.status == '0') { //开启点赞且状态为选中点赞框
								this.status = '1'
							} else {
								if (this.nowPage > 1) { //当前页数不是第一页
									this.nowPage--; //上一页
									position = 'previous';
								} else if (this.structure == 2&&this.nowPage==1) {
								} else if (this.direction != '') {
									direction = this.direction;
								}
							}
							break;
						case 'forwards': //右
							this.status = this.status == '1' && this.isLike ? '0' : '1';
							if (this.status == '1' && this.nowPage != this.totalPage) { //不是最后一页
								this.nowPage++; //下一页
								position = 'next';
							}
							break;
						case 'up': //上
							if (this.status == '1') {
								if (this.index == 0 && this.nowPage > 1) { //在最上面的位置且不是第一页
									this.nowPage--; //上一页
									position = 'previous';
								} else if (this.structure == 2 && this.index == 0 && this.nowPage == 1) {
                                    direction = this.direction;
                                } else if (this.index > 0) {
									this.index--;
								}
							}
							break;
						case 'down': //下
							if (this.status == '1' && ++this.index >= this.length && this.nowPage != this.totalPage) { //不是在最后一页
								this.nowPage++; //下一页
								position = 'next';
							}
							if (this.index >= this.length) {
								this.index = this.length - 1;
							}

							break;
						case 'pageUp': //上一页
							if (this.nowPage > 1) {
								this.nowPage--; //上一页
								position = 'previous';
							}
							break;
						case 'pageDown': //下一页
							if (this.nowPage != this.totalPage) {
								this.nowPage++; //下一页
								position = 'next';
							}
							break;
					}
					break;
				case 2: //单行多列

					var munden = this.rowHeight;
					switch (this.key) {
						case 'backwards': //左
							if (this.structure == 1 && this.nowPage == 1 && this.index == 0) {
								direction = this.direction;
							} else if (this.nowPage <= this.totalPage && this.nowPage > 1 && this.index == 0) {
								this.nowPage--; //上一页
								position = 'previous';
							} else {
								if(this.index>0)
								this.index--;
							}
							break;
						case 'forwards': //右
							if (this.status == '1' && ++this.index >= this.length && this.nowPage != this.totalPage) { //不是在最后一页
								this.nowPage++; //下一页
								position = 'next';
							}
							if (this.index >= this.length) {
								this.index = this.length - 1;
							}
							break;
						case 'up': //上

							if (this.isLike && this.status == '0') { //开启点赞且状态为选中点赞框
								this.status = '1'
							} else {
								if (this.nowPage > 1) { //当前页数不是第一页
									this.nowPage--; //上一页
									position = 'previous';
								} else if (this.nowPage == 1 && this.index < munden && this.structure == 1) {
									if (this.isMenu) {
										direction = "menulist";
									}
								} else if (this.structure == 2 && this.nowPage == 1) {
                                    direction = this.direction;
                                } else if (this.index >= munden) {
									this.index -= munden;
								}
							}
							break;
						case 'down': //下
							if (this.isLike && this.status == '1') { //开启点赞且状态为选中点赞框
								this.status = '0'
							} else if (this.status == '1' && this.nowPage != this.totalPage) { //不是最后一页
								this.nowPage++; //下一页
								position = 'next';
							} else if (this.index < this.pageSize - this.index) {
								this.index += munden;
							}
							if (this.index >= this.length) {
								this.index = this.length - 1;
							}
							break;
						case 'pageUp': //上一页
							if (this.nowPage > 1) {
								this.nowPage--; //上一页
								position = 'previous';
							}
							break;
						case 'pageDown': //下一页
							if (this.nowPage != this.totalPage) {
								this.nowPage++; //下一页
								position = 'next';
							}
							break;
					}
					break;
				case 3: //多行多列
					var munden = this.pageSize / this.rowHeight;
					// // console.log(munden)
					switch (this.key) {
						case 'backwards': //左
							if (this.status == '1') { //开启点赞且状态为选中点赞框
								if (this.direction != '' && this.nowPage == 1 && this.index == 0 && this.structure == 1) {
									direction = this.direction;
								} else if (this.nowPage > 1 && this.index == 0) { //非第一页且第一个位置
									this.nowPage--; //上一页
									position = 'previous';
								} else if (this.index > 0) {
									this.index--;
								}
							}
							break;
						case 'forwards': //右
							if (this.status == '1' && ++this.index >= this.length && this.nowPage != this.totalPage) { //当在最一个位置且并不是最后一页的时候 
								this.nowPage++; //下一页
								position = 'next';
							} else if (this.nowPage == this.totalPage && this.index == this.length) {
								this.index--;
							}
							break;
						case 'up': //上
							if (this.isLike && this.status == '0') {
								this.status = '1'
							} else {
								if (this.direction != '' && this.index < munden && this.nowPage == 1 && this.structure == 2) {
									direction = this.direction;
								} else if (this.index >= 0 && this.index < munden && this.nowPage > 1) { //当前页数不是第一页且是最上面的一行
									this.nowPage--; //上一页
									position = 'previous';
								} else if (this.nowPage == 1 && this.index < munden && this.structure == 1) {

									if (this.isMenu) {
										direction = "menulist";
									}

								} else if (this.index >= munden) {
									this.index -= munden;
								}
							}
							break;
						case 'down': //下
							this.status = this.status == '1' && this.isLike ? '0' : '1';
							if (this.status == '1') {
								if (this.index >= this.pageSize - munden && this.nowPage != this.totalPage) { //当位置在最下面一行且并不是最后一页
									this.nowPage++; //下一页
									position = 'next';
								} else if (this.index < this.pageSize - this.index) {
									this.index += munden;
								}
								if (this.index >= this.length) {
									this.index = this.length - 1;
								}
							}
							break;
						case 'pageUp': //上一页
							if (this.nowPage > 1) {
								this.nowPage--; //上一页
							}
							break;
						case 'pageDown': //下一页
							if (this.nowPage != this.totalPage) {
								this.nowPage++; //下一页
								position = 'next';
							}
							break;
					}
					break;
				default:
					break;
			}

			var backJson = {
				direction: direction, //非单列表情况，返回的位置
				index: this.index, //当前位置
				status: this.status, //外框内框
				nowPage: this.nowPage, //当前页数
				position: position //上一页 or 下一页
			}
			return backJson;
		}
	}
	//导航操作
	TV.MenuOperation = function (json) {
		this.flag = 0;
		this.type = json.type || 1;
		this.directive = json.directive;
		this.isContent = json.isContent || false;
		this.modelType = json.modelType;
		this.index = json.index;
		this.modelName = json.modelName;
		this.nowPage = json.nowPage;
		this.totalPage = json.totalPage;
		this.length = json.length;
		this.pageSize = json.pageSize;
	}

	TV.MenuOperation.prototype = {
		init: function () {
			this.Operation();
		},
		operation: function () {
			this.backRoute = ''
			if ((this.directive == 'down' && this.type == 2) || (this.directive == 'forwards' && this.type == 1)) {
				if (this.isContent || (this.directive == 'forwards' && this.modelType == '0')) {
					this.backRoute = this.modelName
				} else if (is_menu) {
					this.backRoute = "menulist"
				}
			} else if ((this.directive == "up" && this.type == 1) || (this.directive == "backwards" && this.type == 2)) { //减减减
				// console.log('-----')
				if (--this.index < 0 && this.nowPage != 1) {
					this.index = this.pageSize - 1;
					this.nowPage--;
					this.flag = 1;
				} else if (this.index < 0 && this.nowPage == 1 && this.totalPage > 1) {
					this.index = 0;
				} else if (this.totalPage == 1 && this.index < 0) {
					this.index = this.length - 1;
				}
			} else if (this.directive == "down" || this.directive == 'forwards') { //加加加
				// console.log('+++++')
				if (++this.index == this.pageSize && this.totalPage != this.nowPage) {
					this.nowPage++;
					this.index = 0;
					this.flag = 1;
				} else if (this.nowPage == this.totalPage && this.index == this.length && this.totalPage > 1) {
					this.index = this.length - 1;
				} else if (this.totalPage == 1 && this.index == this.length) {
					this.index = 0;
				}

			} else {
				return;
			}

			return {
				nowPage: this.nowPage,
				flag: this.flag,
				index: this.index,
				backRoute: this.backRoute
			}
		}
	}

	//cookie操作
	TV.CookieOpt = function (json) { //是否是返回,index
		this.json = json ? json : {};
	}
	TV.CookieOpt.prototype = {

		cookieName: 'TV__CST_' + window.location.pathname + window.location.search,

		clean: function () {
			$.cookie(this.cookieName, null);
		},
		setOpt: function () {
			this.cookieTv = $.cookie(this.cookieName);
			// console.log(this.cookieTv)
			if (this.cookieTv && this.cookieTv != 'null') {
				$.cookie(this.cookieName, null);
			} else {
				var cookieValue = '';
				for (var key in this.json) {
					cookieValue += '&' + key + '=' + this.json[key];
				}
				// var cookieValue = 'leftPage=' + this.leftPage + '&leftIndex=' + this.leftIndex + '&rightPage=' + this.rightPage + '&index=' + this.index;
				$.cookie(this.cookieName, cookieValue, {
					expires: 1
				});
			}
		},
		getOpt: function () {
			this.cookieTv = $.cookie(this.cookieName);
			// console.log(this.cookieTv)

			if (this.cookieTv) {
				var cookList = this.cookieTv.split("&");
				// // console.log(cookList)
				cookList.shift();
				var json = {};
				for (var i = 0; i < cookList.length; i++) {
					var arr = cookList[i].split('=');
					json[arr[0]] = parseInt(arr[1]);
				}
				$.cookie(this.cookieName, null);
				return json;
			}

		}

	}

	if (typeof window === 'object') {
		window.TV = TV;
	}
}(window))

//  页面统计
0 && (function () {
	debugger
	var GetUrl = function () {
		debugger
		this.flag = 0;
		this.id = 0;
		this.tjapi = API_URL.loginURL;
		this.tpe = 1;
		this.platf = 0;
		this.detailId = 0;
		this.locationUrl = window.location.href;
	}
	GetUrl.prototype = {
		init: function () {
			this.urlOpt();
		},
		urlOpt: function () {
			this.arr = this.locationUrl.split('?')
			// console.log(this.arr)
			if (this.arr.length > 0) {
				var nameList = [];
				nameList = this.arr[0].split('/')
				this.name = nameList[nameList.length - 1]
				if (this.arr.length == 2) {
					this.id = TV.GetParam('id') ? TV.GetParam('id') : 0
					// console.log(this.id)
				}
			}
			this.postview();
		},
		postview: function () {
			switch (this.name) {
				case '':
					this.platf = 99;
					break;
				case 'theoretical.html':
					this.platf = 1;
					break;
				case 'education.html':
					this.platf = 2;
					break;
				case 'culture.html':
					this.platf = 3;
					break;
				case 'science.html':
					this.platf = 4;
					break;
				case 'volunteer.html':
					this.platf = 6;
					break;
				case 'sports.html':
					this.platf = 5;
					break;
				case 'infoListActivity.html':
					this.tpe = 2;
					break;
				case 'play.html':
					this.flag = 1;
					break;
				case 'detailPage.html':
					this.detailId = this.id;
					break;
				default:
					this.platf = 0;
					break;
			}
			// console.log(this.platf)
			if (this.flag == 0 && 0) {
				var params = {
					device: 'tv',
					cardNo: 666,
					platf: this.platf,
					tpe: this.tpe,
					category: this.id,
					id: this.detailId
				}
				http(this.tjapi + '/api/v2/commons/postview', params, function (err, res) {
					console.log(res)
				})
			}
		},
	}
	return new GetUrl().init();
}())

function runLight() {
	var par = {

	}
	var strings = "<marquee class=runLight >欢迎您进入凤阳新时代文明实践中心！</marquee>";
	$("body").append(strings);
	// GetDatas('runLight', par, function (err, res) {
	// 	var str = res.data

	// });

}

$("body").ready(function () {
	if (pageName != 'play.html') {
		var titles = TV.GetParam("titles");
		if (pageName == 'index.html') {
			titles = "<div><img class=t-img src=images/title-index.png /></div>";
		} else {
			// titles = "<img class=t-img src=images/title-" + titles + ".png />";
			titles = "<div class=titleBox>" + titles + "</div>";

		}
		var str = '<div class=titlest>' + '<img src="images/logo.png"/>' + titles + '</div>';
		$('body').append(str);
	}
	runLight()
})